<template>
  <div>
    <Search :tipsKeys="tipKeys" :hotKeys="hotKeys" v-on:go-back="goBack" v-on:search="search"></Search>
  </div>
</template>

<script>
  import search from '@/components/search';
  import { SEARCH_SET_VALUE } from '../store/mutation-types';
  export default {
    components: {
      Search: search
    },
    data() {
      return {
        tipKeys: ['杭州', '宁波', '金华', '温州', '绍兴', '嘉兴', 'tips'],
        hotKeys: ['skr', 'nba', '库里', '科比', '韦德', '勒布朗', '湖人']
      };
    },
    methods: {
      goBack() {
        console.log('will go back');
        this.goBackAndSendValue('');
      },
      search(value) {
        console.log('search data: ', value);
        this.goBackAndSendValue(value);
      },
      goBackAndSendValue(value) {
        this.$store.dispatch('search/' + SEARCH_SET_VALUE, value);
        wx.navigateBack();
      }
    }
  };
</script>
